package com.example.wxchatdemo.Files;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.example.wxchatdemo.R;

import java.util.LinkedList;

public class  ImgsAdapter extends BaseAdapter {

private LinkedList<String> mData;
private Context mContext;
private int indexx=0;

public ImgsAdapter(LinkedList<String> mData, Context mContext) {
        this.mData = mData;
        this.mContext = mContext;
        }

public ImgsAdapter() {
        }

@Override
public int getCount() {
        return mData.size();
        }

@Override
public Object getItem(int position) {
        return mData.get(position);
        }

@Override
public long getItemId(int position) {
        return  position;
        }

@Override
public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.imgs_layout,parent,false);
        ImageView imageView=(ImageView) convertView.findViewById(R.id.imgs);

if (mData!=null) {
        if (mData.get(position).contains("jpg") || mData.get(position).contains("png")) {
                imageView.setImageURI(Uri.parse(mData.get(position)));

        } else {
                imageView.setImageURI(Uri.parse("/storage/emulated/0/AppFiles/txt.jpg"));

        }
}
        return convertView;

        }


        }